<template>
	<uni-easyinput :inputBorder="true" class="w-form-input" @blur="format" v-if="!readonly" v-model="_value" :placeholder="formProps.placeholder? $t(formProps.placeholder) : $t('webAuto.enterNumericalValue')"/>
	<text class="w-form-input-rv" v-else>{{_value}}</text>
</template>

<script setup>
	import {computed} from 'vue'
	import {parseNumber} from '@/utils/tool.js'
	
	const props = defineProps({
		formProps: {
			type: Object,
			default: () => {
				return {}
			}
		},
		modelValue: Number | String,
		readonly: Boolean
	})
	
	function format(){
		emits('update:modelValue', parseNumber(props.modelValue, props.formProps.precision))
	}

	const _value = computed({
		get() {
			return props.modelValue
		},
		set(val) {
			emits('update:modelValue', val)
		}
	})
	
	const emits = defineEmits(['update:modelValue'])

</script>

<style>
</style>